package vip.xiaonuo.pay.modular.alipay.utils;


import vip.xiaonuo.pay.modular.alipay.entity.AliPayRecord;

import java.util.Map;

/**
 * 支付回调参数转entity
 */
public class ParamsToBeanUtils {

    public static AliPayRecord payParamsToBean(Map<String, String> params) {

        AliPayRecord payRecord = new AliPayRecord();

        String tradeNo = params.get("trade_no");
        String outTradeNo = params.get("out_trade_no");
        String buyerLogonId = params.get("buyer_logon_id");
        String tradeStatus = params.get("trade_status");
        String totalAmount = params.get("total_amount");
        String buyerPayAmount = params.get("buyer_pay_amount");
        String subject = params.get("subject");

        payRecord.setTradeNo(tradeNo).setOutTradeNo(outTradeNo)
                .setBuyerLogonId(buyerLogonId).setTradeStatus(tradeStatus)
                .setTotalAmount(totalAmount).setBuyerPayAmount(buyerPayAmount)
                .setCallBackParams(params.toString()).setSubject(subject);

        return payRecord;
    }

}
